package com.moji.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moji.entity.MjAboutUs;
import com.moji.entity.MjAgreement;
import com.moji.mapper.MjAgreementMapper;
import com.moji.service.MjAgreementService;
import com.moji.util.MoJiCommonUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 协议相关表 服务实现类
 * </p>
 *
 * @author ccl
 * @since 2024-08-19
 */
@Service
public class MjAgreementServiceImpl extends ServiceImpl<MjAgreementMapper, MjAgreement> implements MjAgreementService {

    @Override
    public boolean edit(MjAgreement mjAgreement) {
        MjAgreement byId = this.getById(mjAgreement.getId());
        if (byId == null) {
            throw new RuntimeException("数据不存在,请核查!");
        }
        BeanUtils.copyProperties(mjAgreement, byId);
        byId.setUpdateTime(new Date());
        return this.updateById(mjAgreement);
    }

    @Override
    public MjAgreement detail(Long id) {
        if (ObjectUtil.isEmpty(id)) {
            throw new RuntimeException("主键ID不能为空,请核查!");
        }
        return this.getById(id);
    }
}
